package com.wtgroup.demo.面试题.我的面试;

/**
 *
 * 高德工作地图
 *
 * @author nisus
 * @version 0.1
 * @since 2023/6/5 11:03
 */
public class Q_翻转链表 {


    // 链表翻转

    class Node {
        int value;
        Node next;
        public Node(int value) {
            this.value = value;
        }
    }

    class Solution {
        Node main(Node head) {

            return func(head);
        }

        Node func(Node head) {
            if (head == null || head.next == null) {
                return head;
            }

            Node next = head.next;
            Node rest = func(next);
            next.next = head;
            head.next = null;

            return rest;
        }

    }




}
